<?php

// 本类由系统自动生成，仅供测试用途
class AddgoodsAction extends Action {

    public function index() {
        $this->display();
    }

    public function create() {

        $goods = M('goods');
        if ($_POST['goodsname'] == NULL) {
            $this->error('请填写货物名称！');
        }
        if ($_POST['goodsprice'] == NULL) {
            $this->error('请填写货物价格！');
        }
        $data['goodsname'] = $_POST['goodsname'];
        $data['goodsprice'] = $_POST['goodsprice'];
        $data['remark'] = $_POST['goodsremark'];
        if ($goods->add($data)) {
            $this->success('货物新增成功！');
            $this->redirect('Admin/Setgoods/index');
        } else {
            $this->error('货物新增失败！');
        }
    }

}